class Category {

	String name
	String label
	int displayOrder = 0
	
	static hasMany = [jobs:Job]

	static constraints = {
		name(blank:false, matches:/^[a-z0-9_-]{4,30}$/, unique:true)
		label(blank:false)
		displayOrder(nullable:false, unique:true)
	}
	
	String toString() {
		label
	}
	
	def countJobs() {
		Job.countByCategory(this)
	}
}
